home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6562 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.8 KB  |  83 lines

  1. Path: qualcomm.com!usenet
  2. From: nabbasi@qualcomm.com (Nasser Abbasi)
  3. Newsgroups: comp.lang.ada,comp.lang.c++,comp.lang.c
  4. Subject: Re: C++ vs Ada for large project
  5. Date: 9 Feb 1996 13:57:14 GMT
  6. Organization: QUalcomm Inc.
  7. Message-ID: <4ffjrq$i8k@qualcomm.com>
  8. References: <w4wx5wc1a2.fsf@cln46ac>
  9. NNTP-Posting-Host: annex-p26.qualcomm.com
  10. X-Newsreader: WinVN 0.90.4
  11.  
  12. In article <w4wx5wc1a2.fsf@cln46ac>, pascalo@cln46ac (Pascal OBRY) says:
  13. >
  14. >
  15. >Nasser,
  16. >
  17. >> It seems to me the most important part to have a language 
  18. >> considered suitable for large applications is the ability to 
  19. >> separate the interface from the implementation and things like 
  20. >> separate compilation. and to a lesser extent the ability 
  21. >> to do code reuse through taking advantage of inheritance 
  22. >> (i.e. child classes can share code from common parent  class as an 
  23. >> example) or though use of generic packages or templates. 
  24. >>
  25. >
  26. >I don't want to start a language war there but there is no such 
  27. >feature in C++. A convention is that filename.hh contain the 
  28. >interface for filename.cc but nothing more. You can, and in many 
  29. >project I've seen it has been done, add some variables or functions 
  30. >in the .hh that has nothing to do with the package and are implemented 
  31. >in another .cc.
  32. >
  33. >I know that you speak about ability but the important thing is that 
  34. >it should be enforced by the language. That way you can rely on your
  35. >software (you know that nobody has done something wrong).
  36.  
  37. Let me make sure I understand you.
  38.  
  39. example: in C++, one does
  40.  
  41. file: classtype.h
  42. class classType{ public: foo(); } ;   // interface declaration
  43.  
  44. file: classtype.cxx
  45. classType::foo()
  46. { ... some code ...}  // implementation
  47.  
  48. You are saying that in classtype.h file, one can add things like
  49. function declarations that has nothing to do with the logical 
  50. functionality of the class:
  51.  
  52. file: classtype.h
  53. int some_function();  <--   this really do not belong in this file
  54. int global_variable;  <---- since it is not used by clients to this class
  55. class classtype {....};
  56.  
  57.  
  58. that is correct, one can be sloppy and do this, and C++ can not
  59. stop you from doing this.
  60.  
  61. But in Ada one can also be sloppy like the above in C++, by adding type
  62. definitions and subprograms specifications  inside an exisiting 
  63. package interface that logicaly do not belong there. (A term such
  64. as low cohesion between the package components can be used to describe 
  65. this), and these additional entries in the package probably need to be
  66. collected  in a separate package. So , How will Ada prevent you from 
  67. doing this? As an example:
  68.  
  69. In Ada, I can say
  70.  
  71. Package File_Operations is
  72.   procedure Open_File(..);   -- open file
  73.  
  74.   procedure Is_Prime(...);   -- find if a number is prime number
  75.                              -- This certinaly do not belong in this 
  76.                              -- package
  77. end File_Operations;
  78.  
  79. I do not see a big difference. 
  80.  
  81. thanks
  82. Nasser
  83.